<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20101227;15103900">
	<STYLE TYPE="text/css">
	<!--
		@page { size: 8.27in 11.69in }
	-->
	</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P><BR><BR>
</P>
<P STYLE="text-decoration: none"><FONT SIZE=6 STYLE="font-size: 22pt"><B>More
variables – Gradient available</B></FONT></P>
<P STYLE="text-decoration: none"><FONT SIZE=6 STYLE="font-size: 22pt"><B>rnk1min</B></FONT></P>
<P>Determines a vector x \in R^n for which the real valued function
F(x) assumes a minimum value.</P>
<P><BR><BR>
</P>
<P><B>Example: Can be run with F5 within the ScalaLab Editor (Ctrl-E
to open the editor)</B></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">import
java.text.DecimalFormat;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">import numal.*;</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public class Test_rnk1min
extends Object</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">implements AP_linemin_method
{</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public static void
main(String args[]) {</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">boolean again;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double f;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double x[] = new double[3];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double g[] = new double[3];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double h[] = new double[4];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double in[] = new double[9];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double out[] = new double[5];</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">Test_rnk1min testrnk1min =
new Test_rnk1min();</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">DecimalFormat fiveDigit = new
DecimalFormat(&quot;0.00000E0&quot;);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">in[0]=1.0e-6;
in[1]=in[2]=1.0e-5; in[3]=1.0e-4;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">in[4]=1.0e-5; in[5] = -10.0;
in[6]=1.0; in[7]=100.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">in[8]=0.01;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">x[1] = -1.2; x[2]=1.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">again=true;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">f=Analytic_problems.rnk1min(2,x,g,h,testrnk1min,in,out);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">while (true) {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">System.out.println(&quot;\nLeast
value: &quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(f) + &quot;\nx:
&quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(x[1]) + &quot;
&quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(x[2]) +
&quot;\nGradient: &quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(g[1]) + &quot;
&quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(g[2]) +
&quot;\nMetric: &quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(h[1]) + &quot;
&quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(h[2]) + &quot;\n
&quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot; &quot; +
fiveDigit.format(h[3]) + </FONT>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot;\nOUT: &quot; +
fiveDigit.format(out[0]) +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot;\n &quot; +
fiveDigit.format(out[1]) +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot;\n &quot; + (int)out[2]
+</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot;\n &quot; + (int)out[3]
+</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">&quot;\n &quot; +
(int)out[4]);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">if (again) {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">x[1] = -1.2; x[2]=1.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">again=false;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">f=Analytic_problems.flemin(2,x,g,h,testrnk1min,in,out);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">} else</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">break;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><BR><BR>
</P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public double funct(int n,
double x[], double g[])</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">{</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double temp;</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">temp=x[2]-x[1]*x[1];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">g[1]=(-temp*400.0+2.0)*x[1]-2.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">g[2]=temp*200.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">return
temp*temp*100.0+(1.0-x[1])*(1.0-x[1]);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
</BODY>
</HTML>